// Clouds.cpp: implementation of the Clouds class.
//
//////////////////////////////////////////////////////////////////////

#include "Clouds.h"

static sgVec4 base_fog_color    = { 0.84f, 0.87f, 1.00f, 1.0f } ;

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Clouds::Clouds(ssgaSky *sky)
{
  /* give a name to the cloud layers */
  cloudNameList[0] = "Cloud 0";
  cloudNameList[1] = "Cloud 1";
  cloudNameList[2] = "Cloud 2";
  cloudNameList[3] = NULL;

  /* Create the cloud layers */
  clouds[0] =  sky -> addCloud (
				 "./SkyObjects/Clouds/data/scattered.rgba", // texture
                 80000,                 // span
				 2000,                  // elevation,
				 100,                   // thickness
				 100 );                 // transition
  clouds[0] -> setSpeed ( 50 ) ;
  clouds[0] -> setDirection ( 45 ) ;
  clouds[1] =  sky -> addCloud (
				 "./SkyObjects/Clouds/data/scattered.rgba", // texture
                 80000,                 // span
				 3000,                  // elevation,
				 100,                   // thickness
				 100 );                 // transition
  clouds[1] -> setSpeed ( 20 ) ;
  clouds[1] -> setDirection ( 30 ) ;
  clouds[2] =  sky -> addCloud (
				 "./SkyObjects/Clouds/data/scattered.rgba", // texture
                 80000,                 // span
				 1000,                  // elevation,
				 100,                   // thickness
				 100 );                 // transition
  clouds[2] -> setSpeed ( 5 ) ;
  clouds[2] -> setDirection ( 20 ) ;


  /* set the initial brightness */
  this->brightness = 0.5f;

  /* set cloud and fog color */
  cloud_color[0] = fog_color[0] = base_fog_color[0] * brightness;
  cloud_color[1] = fog_color[1] = base_fog_color[1] * brightness;
  cloud_color[2] = fog_color[2] = base_fog_color[2] * brightness;
  cloud_color[3] = fog_color[3] = base_fog_color[3];
}

Clouds::~Clouds()
{

}

void Clouds::setBrightness(float b)
{
  this->brightness = b;

  /* update cloud and fog color */
  cloud_color[0] = fog_color[0] = base_fog_color[0] * brightness;
  cloud_color[1] = fog_color[1] = base_fog_color[1] * brightness;
  cloud_color[2] = fog_color[2] = base_fog_color[2] * brightness;
  cloud_color[3] = fog_color[3] = base_fog_color[3];
}

sgVec4* Clouds::getCloudColor(void)
{
	return &(this->cloud_color);
}

sgVec4* Clouds::getFogColor(void)
{
	return &(this->fog_color);
}